package com.xh.common.thread;

import android.os.Process;

import com.xh.common.thread.ext.executor.ThreadPolicy;

public enum Priority implements ThreadPolicy {

    // 修改这里的level值时，同时需要修改ThreadPool中构建时初始化的level等级。
    // 其中threadPriority目前不生效。

    /* 优先级最高，会启用2级线程池 */
    IMMEDIATE(2, Process.THREAD_PRIORITY_DEFAULT, 1),

    /* 优先级较高，使用1级线程池 */
    HIGH(1, Process.THREAD_PRIORITY_DEFAULT, 0),

    /* 优先级正常，使用1级线程池 */
    NORMAL(0, Process.THREAD_PRIORITY_DEFAULT, 0),

    /* 优先级正常，使用1级线程池 */
    LOW(-1, Process.THREAD_PRIORITY_BACKGROUND, 0),

    /* 优先级正常，使用1级线程池 */
    LOWEST(-2, Process.THREAD_PRIORITY_BACKGROUND, 0);

    private int mLevel;
    private int mPriority;
    private int mThreadPriority;

    Priority(int priority, int threadPriority, int level) {
        mLevel = level;
        mPriority = priority;
        mThreadPriority = threadPriority;
    }

    @Override
    public int getPriority() {
        return mPriority;
    }

    @Override
    public int getThreadPriority() {
        return mThreadPriority;
    }

    @Override
    public int getLevel() {
        return mLevel;
    }
}
